#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int majorityElement(int* nums, int numsSize)
{
    int i;
    unsigned short num[50000] = {0};
    for (i = 0; i < numsSize; i++)
        num[*(nums + i)]++;
    for (i = 0; i < numsSize; i++)
    {
        if (num[*(nums + i)] > numsSize / 2)
        {
            return *(nums + i);
        }
    }
}

int main()
{
    int nums[20] = {1,2,3,1,1,1,1,1,1,1,1,1,4,3,3,3,3,3,3,3};
    printf("%d", majorityElement(nums, 20));
	return 0;
}